/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	SPasswordInfoConverter.java
 * Created：		2016年7月30日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.statement.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.palmmall.rest.statement.AStatementQueryResult;
import com.thor.palmmall.spi.common.SQueryResultConverter;
import com.thor.palmmall.spi.statement.SStatementQueryResult;

/**
 * @author wolv
 *
 */
public class AStatementQueryResultConverter implements Converter<SStatementQueryResult, AStatementQueryResult> {

	public static AStatementQueryResultConverter getInstance() {
		if (instance == null)
			instance = new AStatementQueryResultConverter();
		return instance;
	}

	private static AStatementQueryResultConverter instance;

	private AStatementQueryResultConverter() {
	}

	@Override
	public AStatementQueryResult convert(SStatementQueryResult source) {
		if (source == null)
			return null;

		AStatementQueryResult target = new AStatementQueryResult();
		target.setPayedTotal(source.getPayedTotal());
		target.setPayTotal(source.getPayTotal());
		target.setReceiptRate(source.getReceiptRate());
		target.setResult(SQueryResultConverter.convert(source.getResult(), AStatementConverter.getInstance()));
		target.setUnpayedTotal(source.getUnpayedTotal());

		return target;
	}

}
